package draftMate.player;

public class Pitcher implements Comparable<Pitcher> {
	private static final int NUM_STATS = 7;
	private static final int W = 0;
	private static final int ER = 1;
	private static final int BB = 2;
	private static final int H = 3;
	private static final int IP = 4;
	private static final int K = 5;
	private static final int S = 6;
	private static final int NAME = 7;
	
	private String name;
	private int stats[];
	private int compField;
	
	public Pitcher(String name, int wins, int eR, int walks, int hits, int ip,
			int k, int saves) {
		super();
		this.name = name;
		stats[W] = wins;
		stats[ER] = eR;
		stats[BB] = walks;
		stats[H] = hits;
		stats[IP] = ip;
		stats[K] = k;
		stats[S] = saves;
		compField = NAME;
	}
	
	public String getName() {
		return name;
	}
	public int getWins() {
		return stats[W];
	}
	public void setWins(int wins) {
		stats[W] = wins;
	}
	public int getER() {
		return stats[ER];
	}
	public void setER(int eR) {
		stats[ER] = eR;
	}
	public int getWalks() {
		return stats[BB];
	}
	public void setWalks(int walks) {
		stats[BB] = walks;
	}
	public int getHits() {
		return stats[H];
	}
	public void setHits(int hits) {
		stats[H] = hits;
	}
	public int getIp() {
		return stats[IP];
	}
	public void setIp(int ip) {
		stats[IP] = ip;
	}
	public int getK() {
		return stats[K];
	}
	public void setK(int k) {
		stats[K] = k;
	}
	public int getSaves() {
		return stats[S];
	}
	public void setSaves(int saves) {
		stats[S] = saves;
	}

	public int compareTo(Pitcher p) {
		if (compField == NAME) {
			return name.compareTo(p.name);
		}
		
		if (this.stats[compField] < p.stats[compField]) {
			return -1;
		}
		
		if (this.stats[compField] == p.stats[compField]) {
			return 0;
		}
		
		return 1;
	}
	
	public String toString() {
		return (name + "\t" + stats[W] + "\t" + stats[ER] + "\t" + stats[BB] + "\t" + stats[H] + "\t"
				+ stats[IP] + "\t" + stats[K] + "\t" + stats[S]);
	}
}
